package com.cyj.service.impl;

import com.cyj.dao.AnimeDao;
import com.cyj.entity.Anime;
import com.cyj.entity.User;
import com.cyj.pojo.AnimeVo;
import com.cyj.service.AnimeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("animeService")
@Transactional(rollbackFor = {Exception.class})
public class AnimeServiceImpl implements AnimeService {

    @Autowired
    private AnimeDao animeDao;

    @Override
    public AnimeVo selectAnime(Map map) {
        return animeDao.selectAnime(map);
    }

    @Override
    public List<AnimeVo> selectAllAnimeList(Map map) {
        return animeDao.selectAllAnimeList(map);
    }

    @Override
    public PageInfo<AnimeVo> selectAnimeList(Map map, int pn, int pageSize) {
        PageHelper.startPage(pn,pageSize);

        List<AnimeVo> list = animeDao.selectAnimeList(map);

        PageInfo<AnimeVo> pageInfo = new PageInfo<AnimeVo>(list,5);
        return pageInfo;
    }

    @Override
    public Anime selectAnimeBy(Map map) {
        return animeDao.selectAnimeBy(map);
    }

    @Override
    public Integer updateAnime(Anime anime) {
        return animeDao.updateAnime(anime);
    }

    @Override
    public Integer addAnime(Anime anime) {
        return animeDao.addAnime(anime);
    }
}
